// firstPackage/pages/commissionModule/commissionDetail/commissionDetail.js
import { queryHouseCommissionDetail } from "../../../../service/house_service"
let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    commissionList: [
      {
        type: 1,
      },
      {
        type: 1,
      },
      {
        type: 1,
      },
    ],
    commissionExplainArr: [
      {
        title: "推荐规则",
        text: `1.需在平台上提前40分钟推荐(以客服转发至开发商
为准)
2.推荐信息和购房人信息一致
3.推荐时可选“自己带看”或“委托带看”
4.推荐时间超过当天24:00未到访，则客户下次到
按新客户重新在平台上推荐`
      },
      {
        title: "带看规则",
        text: `1.需在平台上提前40分钟推荐(以客服转发至开发商
为准)
2.推荐信息和购房人信息一致
3.推荐时可选“自己带看”或“委托带看”
4.推荐时间超过当天24:00未到访，则客户下次到
按新客户重新在平台上推荐`
      },
      {
        title: "推荐规则",
        text: `1.需在平台上提前40分钟推荐(以客服转发至开发商
为准)
2.推荐信息和购房人信息一致
3.推荐时可选“自己带看”或“委托带看”
4.推荐时间超过当天24:00未到访，则客户下次到
按新客户重新在平台上推荐`
      },
      {
        title: "认购规则",
        text: `1.需在平台上提前40分钟推荐(以客服转发至开发商
为准)
2.推荐信息和购房人信息一致
3.推荐时可选“自己带看”或“委托带看”
4.推荐时间超过当天24:00未到访，则客户下次到
按新客户重新在平台上推荐`
      },
    ],
    detailId: "",
    detailData: {},
    zcData: null,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      detailId: options.id
    })
    if (JSON.stringify(app.globalData.zcData) != "{}") {
      this.setData({
        zcData: app.globalData.zcData
      })
    }
    this.queryHouseCommissionDetail();
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
  },

  queryHouseCommissionDetail() {
    wx.showLoading();
    queryHouseCommissionDetail(this.data.detailId).then(res => {
      wx.hideLoading();
      console.log("JJLog:佣金详情:" + JSON.stringify(res));
      if (res.code == 200) {
        this.setData({
          detailData: res.data
        })
      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || "查询失败",
        icon: "none"
      })
      console.error("JJLog:queryHouseCommissionDetail", err);
    })
  },

  makePhoneAction() {
    wx.makePhoneCall({
      phoneNumber: '13550307626',
      fail: err => {

      }
    })
  },


  //咨询驻场
  expertPhoneAction() {
    let phone = this.data.zcData.phone;
    wx.makePhoneCall({
      phoneNumber: phone,
      fail: err => {

      }
    })
  },
  //聊天咨询驻场:
  expertChatAction() {
    if (!app.globalData.isLogin) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
      return;
    }
    let item = this.data.zcData;
    let chatData = {
      name: item.realName,
      avatar: item.avatar,
      chatUserId: item.openId,
      conversationType: "C2C",
      expertId: item.id,
      expertPhone: item.phone || "",
      expertWeChat: item.wxChat || "",
    }
    app.globalData.chatData = chatData;
    wx.navigateTo({
      url: '/firstPackage/pages/msgModule/chatRoom/chatRoom',
    })
  },



})